# Maintainer: Andrew Sun <adsun701@gmail.com>

_realname=libfilezilla
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=0.50.0
pkgrel=1
pkgdesc="Small and modern C++ library, offering some basic functionality to build high-performing, platform-independent programs (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'archlinux: libfilezilla'
)
msys2_repository_url="https://svn.filezilla-project.org/filezilla/libfilezilla/trunk/"
msys2_documentation_url="https://lib.filezilla-project.org/doc/"
url="https://lib.filezilla-project.org/"
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
         "${MINGW_PACKAGE_PREFIX}-nettle"
         "${MINGW_PACKAGE_PREFIX}-gnutls")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-autotools"
             "${MINGW_PACKAGE_PREFIX}-gettext")
checkdepends=("${MINGW_PACKAGE_PREFIX}-cppunit")
license=('spdx:GPL-2.0-or-later')
# Upstream download link became (purposely) unstable
# See https://trac.filezilla-project.org/ticket/13186
#source=("https://download.filezilla-project.org/${_realname}/${_realname}-${pkgver}.tar.xz")
source=("https://sources.archlinux.org/other/${_realname}/${_realname}-${pkgver}.tar.xz")
sha256sums=('6d99be1b5a47fbc68aaab83bcc483d84ad170a672eb648a226bf792356455177')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"

  # autoreconf to get updated libtool files with clang support
  autoreconf -fiv
}

build() {
  mkdir -p "${srcdir}"/build-${MSYSTEM} && cd "${srcdir}"/build-${MSYSTEM}

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-static \
    --enable-shared

  make
}

check() {
  cd "${srcdir}"/build-${MSYSTEM}
  # LANG needed to fix string_test::test_conversion2
  LANG=en_US.UTF-8 make check || true
}

package() {
  cd "${srcdir}"/build-${MSYSTEM}
  make install DESTDIR="${pkgdir}"
}
